/**
 * @author yejinbo
 * @description `属性面板`
 */
const _cfg = [
  {
    label: '所占行数',
    struct: 'el-input-number',
    model: 'rows'
  },
  {
    label: '所占列数',
    struct: 'el-input-number',
    model: 'cols'
  },
  {
    label: '对齐方式',
    struct: 'el-select',
    model: 'align',
    hasDefData: 'defChild',
    childStruct: 'el-option',
    defData: [
      {
        label: '左对齐',
        value: 'left'
      },
      {
        label: '右对齐',
        value: 'right'
      },
      {
        label: '居中对齐',
        value: 'center'
      }
    ]
  },
  {
    label: '是否隐藏',
    struct: 'el-switch',
    model: 'hidden'
  },
  {
    label: '只读',
    struct: 'el-switch',
    model: 'readonly'
  }
]
const dsText = [
  {
    label: '标签名:',
    struct: 'el-input',
    model: 'describe'
  },
  {
    label: '字体颜色',
    struct: 'el-color-picker',
    isAttrs: true,
    model: 'color'
  },
  {
    label: '内容',
    struct: 'el-input',
    isAttrs: true,
    model: 'text',
    type: 'textarea'
  }
]
const Input = [
  {
    label: '对应字段',
    struct: 'el-select',
    model: 'value',
    childStruct: 'el-option'
  },
  {
    label: '标签名:',
    struct: 'el-input',
    model: 'describe'
  },
  {
    label: '必选:',
    struct: 'el-switch',
    model: 'isneed'
  },
  {
    label: '类型:',
    struct: 'el-select',
    isAttrs: true,
    model: 'type',
    childStruct: 'el-option',
    items: [
      {
        label: '输入框',
        value: 'text'
      },
      {
        label: '文本域',
        value: 'textarea'
      }
    ]
  },
  {
    label: '默认值',
    struct: 'el-input',
    isAttrs: true,
    model: 'placeholder'
  }
]
const Switch = [
  {
    label: '对应字段',
    struct: 'el-select',
    model: 'value',
    childStruct: 'el-option'
  },
  {
    label: '激活颜色:',
    struct: 'el-color-picker',
    model: 'active-color',
    isAttrs: true
  },
  {
    label: '未激活颜色:',
    struct: 'el-color-picker',
    model: 'inactive-color',
    isAttrs: true
  },
  {
    label: '激活时提示:',
    struct: 'el-input',
    model: 'active-text',
    isAttrs: true
  },
  {
    label: '未激活时提示:',
    struct: 'el-input',
    model: 'inactive-text',
    isAttrs: true
  },
  {
    label: '组名编辑',
    struct: 'el-input',
    model: 'describe'
  },
  {
    label: '是否必需',
    struct: 'el-switch',
    model: 'isneed'
  },
  {
    label: '级联设置',
    struct: 'cascade-label',
    noModel: true
  }
]
const Button = [
  {
    label: '文字:',
    struct: 'el-input',
    model: 'text'
  },
  {
    isAttrs: true,
    label: '选择类型:',
    struct: 'el-select',
    model: 'type',
    childStruct: 'el-option',
    items: [
      {
        label: '默认(白色)',
        value: 'default'
      },
      {
        label: '绿色',
        value: 'success'
      },
      {
        label: '蓝色',
        value: 'primary'
      },
      {
        label: '红色',
        value: 'danger'
      },
      {
        label: '橙色',
        value: 'warning'
      }
    ]
  },
  {
    label: '组名编辑',
    struct: 'el-input',
    model: 'describe'
  },
  {
    label: '是否必需',
    struct: 'el-switch',
    model: 'isneed'
  },
  {
    label: '对应字段',
    struct: 'el-select',
    model: 'business',
    childStruct: 'el-option'
  },
  {
    label: '级联设置',
    struct: 'cascade-label',
    noModel: true
  },
  {
    label: '事件',
    struct: 'el-input',
    type: 'textarea',
    noModel: true
  }
]
const InputNumber = [
  {
    label: '大小:',
    struct: 'el-select',
    model: 'size',
    isAttrs: true,
    childStruct: 'el-option',
    items: [
      {
        label: '一般',
        value: 'medium'
      },
      {
        label: '较小',
        value: 'small'
      },
      {
        label: '迷你',
        value: 'mini'
      },
      {
        label: '较大',
        value: 'large'
      }
    ]
  },
  {
    label: '步数:',
    model: 'step',
    isAttrs: true,
    struct: 'el-input-number'
  },
  {
    label: '最小值:',
    model: 'min',
    isAttrs: true,
    struct: 'el-input-number'
  },
  {
    label: '最大值:',
    model: 'max',
    isAttrs: true,
    struct: 'el-input-number'
  },
  {
    label: '是否必需',
    struct: 'el-switch',
    model: 'isneed'
  },
  {
    label: '组名编辑',
    struct: 'el-input',
    model: 'describe'
  },
  {
    label: '对应字段',
    struct: 'el-select',
    model: 'business',
    childStruct: 'el-option'
  }
]
const TimePicker = [
  {
    label: '对应字段',
    struct: 'el-select',
    model: 'value',
    childStruct: 'el-option'
  },
  {
    isAttrs: true,
    model: 'size',
    label: '大小:',
    struct: 'el-select',
    childStruct: 'el-option',
    items: [
      {
        label: '一般',
        value: 'medium'
      },
      {
        label: '较小',
        value: 'small'
      },
      {
        label: '迷你:',
        value: 'mini'
      }
    ]
  },
  {
    label: '是否必需',
    struct: 'el-switch',
    model: 'isneed'
  },
  {
    label: '组名编辑',
    struct: 'el-input',
    model: 'describe'
  }
]
const Rate = [
  {
    label: '对应字段',
    struct: 'el-select',
    model: 'value',
    childStruct: 'el-option'
  },
  {
    label: '允许半选:',
    model: 'allow-half',
    struct: 'el-switch',
    isAttrs: true
  },
  {
    label: '最大值:',
    model: 'max',
    struct: 'el-input-number',
    isAttrs: true,
    attrs: {
      max: 10,
      min: 5
    }
  },
  {
    label: '低/中分割值:',
    model: 'low-threshold',
    isAttrs: true,
    struct: 'el-input-number',
    attrs: {
      max: 6,
      min: 1
    }
  },
  {
    label: '中/高分割值:',
    model: 'high-threshold',
    isAttrs: true,
    struct: 'el-input-number',
    attrs: {
      max: 10,
      min: 2
    }
  },
  {
    label: '未选中时颜色:',
    struct: 'el-color-picker',
    model: 'void-color',
    isAttrs: true
  },
  {
    label: '显示分数:',
    struct: 'el-switch',
    model: 'show-score',
    isAttrs: true
  },
  {
    label: '是否必需',
    struct: 'el-switch',
    model: 'isneed'
  },
  {
    label: '组名编辑',
    struct: 'el-input',
    model: 'describe'
  }
]
const Slider = [
  {
    label: '最小值:',
    struct: 'el-input-number',
    model: 'min',
    isAttrs: true
  },
  {
    label: '最大值:',
    struct: 'el-input-number',
    model: 'max',
    isAttrs: true
  },
  {
    label: '步数:',
    struct: 'el-input-number',
    model: 'step',
    isAttrs: true
  },
  {
    label: '是否必需',
    struct: 'el-switch',
    model: 'isneed'
  },
  {
    label: '组名编辑',
    struct: 'el-input',
    model: 'describe'
  },
  {
    label: '对应字段',
    struct: 'el-select',
    model: 'business',
    childStruct: 'el-option'
  }
]
const Upload = [
  {
    label: '对应字段',
    struct: 'el-select',
    model: 'value',
    childStruct: 'el-option'
  },
  {
    isAttrs: true,
    label: '上传地址:',
    model: 'action',
    struct: 'el-input'
  },
  {
    isAttrs: true,
    label: '开启多文件上传:',
    model: 'multiple',
    struct: 'el-switch'
  },
  {
    isAttrs: true,
    label: '支持拖拽上传:',
    model: 'drag',
    struct: 'el-switch'
  },
  {
    isAttrs: true,
    label: '文件列表类型:',
    model: 'list-type',
    struct: 'el-select',
    childStruct: 'el-option',
    items: [
      {
        label: '文本类型',
        value: 'text'
      },
      {
        label: '图片',
        value: 'picture'
      },
      {
        label: '明信片',
        value: 'picture-card'
      }
    ]
  },
  {
    isAttrs: true,
    label: '最大上传个数',
    struct: 'el-input-number',
    model: 'limit'
  },
  {
    label: '描述',
    struct: 'el-input',
    model: 'list'
  },
  {
    label: '是否必需',
    struct: 'el-switch',
    model: 'isneed'
  },
  {
    label: '组名编辑',
    struct: 'el-input',
    model: 'describe'
  }
]
const RadioGroup = [
  {
    label: '对应字段',
    struct: 'el-select',
    model: 'value',
    childStruct: 'el-option',
    for: 'value'
  },
  {
    label: '子项编辑',
    struct: 'el-input',
    model: 'dataUrl'
  },
  {
    label: '组名编辑',
    struct: 'el-input',
    model: 'describe'
  },
  {
    label: '是否必需',
    struct: 'el-switch',
    model: 'isneed'
  },
  {
    label: '级联设置',
    struct: 'cascade-label',
    noModel: true
  }
]
const ButtonGroup = [
  {
    label: '组名编辑',
    struct: 'el-input',
    model: 'describe'
  },
  {
    label: '子项编辑',
    struct: 'mutiple',
    model: 'list'
  }
]
const checkBoxGroup = [
  {
    label: '对应字段',
    struct: 'el-select',
    model: 'business',
    childStruct: 'el-option'
  },
  {
    label: '子项编辑',
    struct: 'mutiple',
    model: 'list'
  },
  {
    label: '组名编辑',
    struct: 'el-input',
    model: 'describe'
  },
  {
    label: '是否必需',
    struct: 'el-switch',
    model: 'isneed'
  },
  {
    label: '级联设置',
    struct: 'cascade-label',
    noModel: true
  }
]
const Select = [
  {
    label: '对应字段',
    struct: 'el-select',
    model: 'value',
    childStruct: 'el-option',
    for: 'value'
  },
  {
    label: '组名编辑',
    struct: 'el-input',
    model: 'describe'
  },
  {
    label: '子项编辑',
    struct: 'el-input',
    model: 'dataUrl'
  },
  {
    label: '是否必需',
    struct: 'el-switch',
    model: 'isneed'
  }
]
const DatePicker = [
  {
    label: '对应字段',
    struct: 'el-select',
    model: 'value',
    childStruct: 'el-option',
    for: 'value'
  },
  {
    label: '组名编辑',
    struct: 'el-input',
    model: 'describe'
  },
  {
    label: '是否必需',
    struct: 'el-switch',
    model: 'isneed'
  }
]
export const conf = {
  'el-input': Input,
  'el-switch': Switch,
  'el-button': Button,
  'el-input-number': InputNumber,
  'el-time-picker': TimePicker,
  'el-rate': Rate,
  'el-slider': Slider,
  'el-upload': Upload,
  'el-radio-group': RadioGroup,
  'el-checkbox-group': checkBoxGroup,
  'el-select': Select,
  'ds-text': dsText,
  'el-button-group': ButtonGroup,
  'el-date-picker': DatePicker
}
//  申请地址，存放模板
const _conf = JSON.parse(JSON.stringify(conf))
/**
 * @argument {elname: '元素名', type: 'form' || 'table'}
 */
export const propsConfig = (elname, type) => {
  type = type || 'form'
  if (type === 'form') return [..._conf[elname], ..._cfg]
  else if (type === 'table') {
    // table op...
    return ''
  }
}
